package com.linkoog.devtools.http.request.http_response.response.response_body.body;

import com.intellij.openapi.project.Project;
import com.intellij.util.ui.JBUI;
import com.linkoog.devtools.http.HttpPluginIcons;
import com.linkoog.devtools.http.request.common.response_body.ErrorResponseBody;
import com.linkoog.devtools.http.request.http_response.response.response_body.BodyPanel;
import com.linkoog.devtools.intellij.editor.PlainTextEditerPanel;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.awt.*;

public class ErrorBodyPanel implements BodyPanel<ErrorResponseBody> {

    private JPanel myMainPanel;

    private JLabel tipLabel;
    private JLabel errorLabel;
    private JLabel iconLabel;


    public ErrorBodyPanel(Project project) {
        tipLabel.setFont(new Font("Consolas", Font.BOLD, 20));
        tipLabel.setText("请求发生错误");

        iconLabel.setBorder(JBUI.Borders.empty(10, 0, 20, 0));
        iconLabel.setIcon(HttpPluginIcons.ERROR_BACKGROUND_ICON);
    }

    @Override
    public void resetResponseBody(@NotNull ErrorResponseBody responseBody) {
        errorLabel.setText(responseBody.getValue());
    }

    @Override
    public JPanel getPanel() {
        return myMainPanel;
    }
}
